#include "widget.h"
#include "ui_widget.h"

#include <QtGui>
#include <QPen>
#include <QStyle>
#include <string>
int start(std::map<QPoint*, int>& indiv_list, std::vector<QRect*>& wall_list, std::vector<QRect*>& extra_wall_list,std::string& outstr);
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    map =ui->map;
    last_label = ui->label_ob_s;
    this->setWindowTitle("人群疏散仿真平台");

}



Widget::~Widget()
{
    delete ui;
}


void Widget::on_Bnt_start_clicked()
{
    std::string outstr;
    start(map->indiv_list,map->wall_list, map->extra_wall_list,outstr);
    ui->label_2->setText(QString(outstr.c_str()));
}


void Widget::on_Bnt_ob_s_clicked()
{
    map->use_type=Map::Wall_S;
    ui->label_ob_s->setFont(QFont("Microsoft YaHei", 9, QFont::Black));
    if(last_label!= ui->label_ob_s)
        last_label->setFont(QFont("Microsoft YaHei", 9, QFont::Normal));
    last_label = ui->label_ob_s;
}


void Widget::on_Bnt_ind_s_clicked()
{
    map->use_type=Map::Indiv_S;
    ui->label_ind_s->setFont(QFont("Microsoft YaHei", 9, QFont::Black));
    if (last_label != ui->label_ind_s)
        last_label->setFont(QFont("Microsoft YaHei", 9, QFont::Normal));
    last_label = ui->label_ind_s;
}


void Widget::on_checkBox_stateChanged(int arg1)
{
    map->is_extra = arg1;
}


void Widget::on_Bnt_ind_m_clicked()
{
    map->use_type = Map::Indiv_M;
    ui->label_ind_m->setFont(QFont("Microsoft YaHei", 9, QFont::Black));
    if (last_label != ui->label_ind_m)
        last_label->setFont(QFont("Microsoft YaHei", 9, QFont::Normal));
    last_label = ui->label_ind_m;
}


void Widget::on_Bnt_ob_m_clicked()
{
    map->use_type = Map::Wall_M;
    ui->label_ob_m->setFont(QFont("Microsoft YaHei", 9, QFont::Black));
    if (last_label != ui->label_ob_m)
        last_label->setFont(QFont("Microsoft YaHei", 9, QFont::Normal));
    last_label = ui->label_ob_m;
}


void Widget::on_lineEdit_textChanged(const QString &arg1)
{
    map->num_indiv = arg1.toInt();
}

